var signInfo = JSON.parse(localStorage.getItem("signInfo"));
var captain = JSON.parse(localStorage.getItem("captain"));
//获取token
var token = localStorage.getItem("token");	
console.log('token：'+token)

hui.formInit();
var selectval;
//获取单选框的值
function showSelectRes(_selfBtn){
    
    hui(_selfBtn).parent().find('input').each(function(cObj){
        if(cObj.checked){selectval = cObj.value;}
    });
    console.log(selectval);
}


hui.ready(function(){
	
	hui('.hos_name').html(captain.hos_name);
	hui('.teamName').html(captain.captain.name);
	hui('.nowtime').html(new Date().toLocaleString());
//	hui('.timeall').html(captain.hos_name);
	hui('#hui-back').click(function(){
//	    hui.toast('返回');
	});
	
	hui('#submitBtn').click(function(){
		if(selectval){	
			console.log(localStorage.getItem("signInfo"))
			hui.ajax({
			    type : 'POST',
			    url : globleobj['domain']+'/residents/sign',
			    data : signInfo,
			    beforeSend : function(){hui.loading();},
			    complete   : function(){hui.closeLoading();},
			    success : function(msg){
			    	console.log('sign'+msg)
			    	var data = JSON.parse(msg);
			    	if(data.rc != 0){
			    		hui.toast(data.msg); 
			    		return false; 
			    	}
			    	
					hui.iconToast('签约完成');
			        setTimeout(function(){
			        	hui.open('/html/locationCommunity/myDoctore.html',{},true);
			        },1000)
			    	
			    },
			    error : function(e){
			        console.log(JSON.stringify(e));
			        hui.iconToast('读取消息失败', 'warn');
			    } 
			}); 
		}else{
			hui.toast('签约需先同意签约条款！');
		}
	});
	
//	//跳转个人中心
//	hui('#nav-my').click(function(){
//	    hui.open('personcenter.html')
//	});
    hui.plusReady(function(){
    	console.log('plusReady')
    });
});